package View.src;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

public class Concourse2 {
    public static void main(String[] args) {
        Concourse2.CreateFrame createFrame=new Concourse2.CreateFrame("Pokemon");
    }
    public static class CreateFrame extends JFrame {//创建边框类

        void Hide(JButton button){//隐藏按钮边框和背景

            button.setContentAreaFilled(false);
            button.setBorderPainted(false);
        }
        public CreateFrame(String title) throws HeadlessException {
            super(title);


            JFrame framer = new JFrame(title);
            framer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            framer.setSize(1250, 720);
            Concourse2.CreateFrame.MyControl myControl=new Concourse2.CreateFrame.MyControl();//实例自定义控件
            framer.setContentPane(myControl);
            framer.setLayout(null);//自定义布局

            ImageIcon imageIcon1=new ImageIcon("image//右箭头.png");
            JButton button1=new JButton(imageIcon1);
            button1.setBounds(1000,500,200,100);
            myControl.add(button1);


            ImageIcon imageIcon2=new ImageIcon("image//左箭头.png");
            JButton button2=new JButton(imageIcon2);
            button2.setBounds(10,500,200,100);
            myControl.add(button2);


            ImageIcon imageIcon3=new ImageIcon("image//设置.png");
            JButton button3=new JButton(imageIcon3);
            button3.setBounds(10,10,50,50);
            myControl.add(button3);

            ImageIcon imageIcon4=new ImageIcon("image//背包栏.png");
            JButton button4=new JButton(imageIcon4);
            button4.setBounds(1100,5,64,64);
            myControl.add(button4);


            Hide(button1);
            Hide(button2);
            Hide(button3);
            Hide(button4);

//            myControl.add(button3);
            framer.setContentPane(myControl);

            framer.setVisible(true);
        }
        public class MyControl extends JPanel{//自定义地图控件

            @Override
            protected void paintComponent(Graphics g) {

                super.paintComponent(g);
                int width = this.getWidth();
                int height = this.getHeight();
                g.setColor(new Color(255, 25, 255));
                g.fillRect(0, 0, width, height);

                Random r=new Random();
                int num=r.nextInt(7)+1;
                File file = new File("image//场景图2.jpg");

                try {
                    BufferedImage image = ImageIO.read(file);
                    g.drawImage(image, 0, 0, width, height, null);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }





        }

    }
}
//主界面


